<!-- 预约审批情况 -->
<template>
	<view>
		<ApproveDetail :item="itemData"></ApproveDetail>
		<!-- 当前预约审批状态为  2未审批 && 当前平台用户为审批人（企业管理员） -->
		<block v-if="item.state=='2'&&(!!webUserInfo) && webUserInfo.user.userId==itemData.updaterid">
			<ApproveHandle :item="itemData"></ApproveHandle>
		</block>
	</view>
</template>

<script>
	import ApproveDetail from "@/pages/approve/components/booking/approve-detail.vue"
	import ApproveHandle from "@/pages/approve/components/booking/approve-handle.vue"
	import {
		Platform,
		Storage_Key
	} from '@/static/config.js';
	import {
		GetRecordState,
		GetApproveState
	} from "@/common/util.js"
	import request from '@/common/request.js';
	export default {
		props: ['item'],
		components: {
			ApproveDetail,
			ApproveHandle
		},
		computed: {
			// wxUserInfo() {
			// 	return this.$storage.get(Storage_Key.user_info, true);
			// },
			webUserInfo() {
				return this.$storage.get(Storage_Key.web_user_info, true);
			},
		},
		data() {
			return {
				itemData: {},
			}
		},
		mounted() {
			this.itemData.bookingid = this.item.id; // 预约ID -- approve-handle用
			this.itemData.state = this.item.state; // 预约审批状态（因为预约审批表没有此字段） -- approve-detail用
			this.itemData = {...this.itemData,...this.item}
			console.log(this.itemData)
			this.loadData();
		},
		methods: {
			// 获取审批详情 by 预约ID
			loadData() {
				let _self = this;
				let totalcount = -1;
				request({
					url: Platform.api_requestUrl + '/stp-booking-approval/GetListDetail',
					data: {
						bookingid: _self.item.id,
						pageIndex: 1,
						pageSize: 100000000,
					},
					method: 'GET',
				}).then(res => {
					if (res.code == 200 && !!res.data.length != 0) {
						_self.itemData = {
							..._self.itemData,
							...res.data[0]
						};
						uni.$emit("approver-info", {
							key: true,
							msg: _self.itemData // 审批人信息
						})
					}
				}).catch(error => {
					console.log("fail")
				});
			},
		}
	}
</script>

<style lang='scss' scoped>

</style>
